//-----------------------------------------------------------------------
// <copyright file="ProcessorUnitTest.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics
{
    using System;
    using System.Reflection;

    using System.Collections;
    using System.Collections.Generic;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Provides unit testing for the <see cref="T:CodePlex.Diagnostics.Processor"/> class.
    /// </summary>
    [TestClass]
    public sealed class ProcessorUnitTest
    {
        #region public ProcessorUnitTest()

        /// <summary>
        /// Initializes a new instance of the <see cref="T:ProcessorUnitTest"/> class.
        /// </summary>
        public ProcessorUnitTest()
        {
        }

        #endregion

        #region public void GetProcessorsTest()

        /// <summary>
        /// Unit test to exercise the <see cref="M:CodePlex.Diagnostics.Processor.GetProcessors"/> static method.
        /// </summary>
        [TestMethod]
        public void GetProcessorsTest()
        {
            IList<Processor> processors = Processor.GetProcessors();

            Assert.IsNotNull(processors, "Processor.GetProcessors() returned null.");

            Assert.IsTrue(processors.Count > 0, "Processor.GetProcessors() returned an IList with a Count of zero.");

            foreach (Processor processor in processors)
            {
                Assert.IsNotNull(processor, "Processor.GetProcessors() returned an IList containing a null Processor instance.");

                Assert.IsFalse(
                    string.IsNullOrEmpty(processor.Name),
                    "Processor.GetProcessors() returned an IList containing a Processor instance with either a null or empty Name property.");
                Assert.IsFalse(
                    string.IsNullOrEmpty(processor.Description),
                    "Processor.GetProcessors() returned an IList containing a Processor instance with either a null or empty Description property.");
                Assert.IsFalse(
                    string.IsNullOrEmpty(processor.Id),
                    "Processor.GetProcessors() returned an IList containing a Processor instance with either a null or empty DeviceId property.");

                Assert.IsNotNull(
                    processor.Architecture,
                    "Processor.GetProcessors() returned an IList containing a Processor instance with a null Architecture property.");

                Assert.IsTrue(
                    processor.AddressWidth == 32 || processor.AddressWidth == 64,
                    "Processor.GetProcessors() returned an IList containing a Processor instance with an invalid AddressWidth property.");
            }
        }

        #endregion
    }
}
